package com.example.demo.queue.blockingQueue;

/**
 * @desc:
 * @author: fuxiang
 * @date: 2018/8/30 16:49
 */
public class Consumer implements Runnable {
    private String instance;
    public Consumer(String instance) {
        this.instance = instance;
    }
    @Override
    public void run() {
        try {
            while (true) {
                // 消费苹果
                System.out.println("消费者准备消费苹果：" + instance);
                Basket.take();
                System.out.println("!消费者消费苹果完毕：" + instance);
                // 休眠1000ms
                Thread.sleep(2000);
            }
        } catch (InterruptedException ex) {
            System.out.println("Consumer Interrupted");
        }
    }
}
